###########################
### Run Counterfactuals ###
###########################
	
# ssubmit --partition=sscc --cores=10 --mem=40g "julia18 run.counterfactuals.zeroresid.jl"
	
##### Simulation parameters
	
	create_standard_errors_flag = false;
	if !create_standard_errors_flag
		year = 2015;
		scenario = "Base";
		cluster_run = true;
	end
	
	zero_resid_flag = true;
	add_complex_interactions = true;
	add_av_interactions = true;
	random_parameters = true;
	ns = 1;
	control_function = true;
	add_insurer_market_fe = true;
	add_silver = false; 
	nested = false;
	keep_two_choices = false;
	ef_approach_flag = false;
	separate_metal_flag = false;
	run_counterfactuals_flag = false;
	process_output_flag = true;
	max_year = 2018;
	
	choice_seq_flag = false;
	av_rs_flag = false;
	all_rs_variables = false;
	int_rs_variables = true;
	old_flag = false;
	hisp_flag = false;
	agegender_flag = false;
	
##### Load Data and Setup Data Objects
	
	if cluster_run
		codedir = "/project/inertia_project/Code";
		datadir = "/project/inertia_project/Data";
	else
		codedir = "C:/Users/eas24f/OneDrive - Florida State University/Research/Inertia RESTAT/Code";
		datadir = "C:/Users/eas24f/OneDrive - Florida State University/Research/Inertia RESTAT/Data";
	end
	
	cd(codedir)
	include("setup.counterfactual.data.jl")
	
##### Forward simulation (if necessary)

	if (year == 2016) & (!no_inertia_flag) & (scenario == "Robust")
		forward_simulated_prev_choices = update_prev_choice(premiums_prev[!,:ACA],X_prev,households_prev,mand_repeal_flag,voucher_flag,no_uninsured_flag);
		X = update_previous_choice_variables(forward_simulated_prev_choices,X,households);
	elseif (year > 2014) & !no_inertia_flag
		forward_simulated_prev_choices = update_prev_choice(premiums_prev[!,Symbol(scenario)],X_prev,households_prev,mand_repeal_flag,voucher_flag,no_uninsured_flag);
		X = update_previous_choice_variables(forward_simulated_prev_choices,X,households);
	end
	
##### Run Counterfactual
	
	prem_initial = [201.2313488
330.4050941
246.9088048
369.6173717
278.1968299
287.2133297
212.7860858
196.7781949
311.1763528
351.4975054
263.2467342
191.1937306
184.2890301
282.808198
240.9671058
344.5808436
270.2273163
242.9654325
211.9212532
183.8116474
283.3438599
317.308628
245.2970356
168.6716385
214.2473958
240.0550557
199.7424829
];
	
	prem_initial = plans[!,:Premium];
	if run_counterfactuals_flag
		eq = nlsolve(foc!,prem_initial,iterations=1000,method=:newton,linesearch=BackTracking(),show_trace=true);
		base_premium = eq.zero;
		CSV.write(premium_file,DataFrame(cat(dims=2,plan_year_names,prem_initial,base_premium),:auto));
	elseif scenario == "ACA"
		base_premium = plans[!,:Premium];
	elseif (scenario == "No_Inertia_NoSupply") & choice_seq_flag
		base_premium = CSV.read(string(year,"Base0_premium_output_intvars_seq_avint.csv"),DataFrame,header=true)[!,:x3];
	elseif scenario == "No_Inertia_NoSupply" 
		base_premium = CSV.read(string(year,"Base0_premium_output_noseq.csv"),DataFrame,header=true)[!,:x3];
	else
		base_premium = CSV.read(premium_file,DataFrame,header=true)[!,:x3];
	end
	
##### Process Output/Calculate Measures of Interest
	
	# Load optimal premiums from above
	if process_output_flag 
		cd(codedir)
		vert_pref = true;
		include("create.supply.output.jl")
	end
	